package work.mediway.mdm.biz.vo.dict;

import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.List;

import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.util.ObjectUtil;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;

/**
 * @author zhongyj <1126834403@qq.com><br/>
 * @date 2021/1/21
 */
@Data
@ApiModel
@JsonInclude(value = JsonInclude.Include.NON_NULL)
public class DictStatisticsVO {

    @ApiModelProperty(value = "本月更新")
    private Integer monthUpdate;

    @ApiModelProperty(value = "本月新增")
    private Integer monthIncrease;

    @ApiModelProperty(value = "今日更新")
    private Integer dayUpdate;

    @ApiModelProperty(value = "今日新增")
    private Integer dayIncrease;

    @ApiModelProperty(value = "字典排名")
    private List<DictChangeTop> dictTop = CollUtil.newArrayList();

    @ApiModelProperty(value = "变化曲线")
    private List<StatisticsVO> change = CollUtil.newArrayList();

    @ApiModelProperty(value = "模型总数")
    private Integer modelTotal;

    @ApiModelProperty(value = "字典总数")
    private Integer dictTotal;

    @ApiModelProperty(value = "系统总数")
    private Integer interSystemTotal;

    @ApiModelProperty(value = "订阅总数")
    private Integer subscribeTotal;

    @ApiModelProperty(value = "数据应用")
    private List<DictPush> dataSubscribe = CollUtil.newArrayList();

    @Data
    public static class StatisticsVO {
        @ApiModelProperty(value = "日期")
        private String date;

        @ApiModelProperty(value = "更新")
        private Integer update;

        @ApiModelProperty(value = "新增")
        private Integer increase;

        @ApiModelProperty(value = "所有字典数据总量")
        private Integer dictTotal;
    }

    @Data
    public static class DictChangeTop {

        @ApiModelProperty(value = "新增")
        private Integer increase;

        @ApiModelProperty(value = "更新")
        private Integer update;

        @ApiModelProperty(value = "总更新")
        private Integer totalChange;

        @ApiModelProperty(value = "字典code")
        private String dictCode;

        @ApiModelProperty(value = "字典名称")
        private String dictName;
    }

    @Data
    public static class DictPush {

        @ApiModelProperty(value = "订阅系统")
        private String subscribeInterSystem;

        @ApiModelProperty(value = "昨日数据出量")
        private Integer outputYesterday;

        @ApiModelProperty(value = "总出量")
        private Integer totalOutput;

        @ApiModelProperty(value = "字典code")
        private String dictCode;

        @ApiModelProperty(value = "字典名称")
        private String dictName;

        public Integer getOutputYesterday() {
            if (ObjectUtil.isEmpty(outputYesterday)) {
                outputYesterday = 0;
            }
            return outputYesterday;
        }

        public Integer getTotalOutput() {
            if (ObjectUtil.isEmpty(totalOutput)) {
                totalOutput = 0;
            }
            return totalOutput;
        }
    }

}
